package com.czy.owner.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.czy.owner.R;
import com.czy.owner.entity.OderSerchLeatlyListModel;
import com.czy.owner.widget.shopbutton.AnimShopButton;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;

import java.util.List;

/**
 * Created by wangyang on 2017/5/18 0018.
 */

public class SelectBespokeTabAdapter extends BaseRecyclerAdapter<OderSerchLeatlyListModel, SelectBespokeTabAdapter.SelectBespokeTabHolder> {
    private Context ctx;
    private String isPostin;

    public SelectBespokeTabAdapter(Context context, List<OderSerchLeatlyListModel> data) {
        super(context, data);
        this.ctx = context;
    }

    public void setIsPostin(String isPostin) {
        this.isPostin = isPostin;
        notifyDataSetChanged();
    }

    public String getIsPostin() {
        return isPostin;
    }

    @Override
    public void onBindViewHolder(SelectBespokeTabHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.bindData(data.get(position), position);

    }

    @Override
    public SelectBespokeTabHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new SelectBespokeTabHolder(layoutInflater.inflate(R.layout.item_select_tab, parent, false));
    }

    public class SelectBespokeTabHolder extends BaseRecyclerAdapter.ViewHolder {
        private TextView rb_statistics_project;

        public SelectBespokeTabHolder(View itemView) {
            super(itemView);
            rb_statistics_project = (TextView) itemView.findViewById(R.id.rb_statistics_project);
        }

        public void bindData(OderSerchLeatlyListModel model, int pos) {
            if (isPostin != null && !isPostin.isEmpty() && Integer.parseInt(isPostin) == pos) {
//                rb_statistics_project.setChecked(true);
                rb_statistics_project.setBackgroundResource(R.drawable.baspoke_search_select_radius_true);
                rb_statistics_project.setTextColor(mContext.getResources().getColor(R.color.white));
            } else {
//                rb_statistics_project.setChecked(false);
                rb_statistics_project.setBackgroundResource(R.drawable.baspoke_search_select_radius);
                rb_statistics_project.setTextColor(mContext.getResources().getColor(R.color.appThemeTextColorBlack));

            }
            rb_statistics_project.setText(model.getServiceName());
        }
    }
}